﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;

    public class AdjustmentDetailDA : IAdjustmentDetailDA
    {
        private string ADJUSTMENT_DATE = "@ADJUSTMENT_DATE";
        private string ADJUSTMENT_ID = "@ADJUSTMENT_ID";
        private string CASE_CNT = "@CASE_CNT";
        private string CREATED_BY = "@CREATED_BY";
        private string CUBE = "@CUBE";
        private string GROSS_WGT = "@GROSS_WGT";
        private string INNER_PACK = "@INNER_PACK";
        private string LINE_ID = "@LINE_ID";
        private string LOC = "@LOC";
        private string LOT = "@LOT";
        private string LPN_ID = "@LPN_ID";
        private string NET_WGT = "@NET_WGT";
        private string OTHER_UNIT1 = "@OTHER_UNIT1";
        private string OTHER_UNIT2 = "@OTHER_UNIT2";
        private string OWNER_ID = "@OWNER_ID";
        private string PACK_ID = "@PACK_ID";
        private string PALLET = "@PALLET";
        private string QTY = "@QTY";
        private string REASON_CODE = "@REASON_CODE";
        private string RECEIPT_ID = "@RECEIPT_ID";
        private string RECEIPT_LINE_ID = "@RECEIPT_LINE_ID";
        private string REFERENCE_ID = "@REFERENCE_ID";
        private string REMARK = "@REMARK";
        private string SKU_ID = "@SKU_ID";
        private string SQL_DELETE_ADJUSTMENT_DETAIL = " DELETE FROM @_@ADJUSTMENT_DETAIL WHERE ADJUSTMENT_ID = @ADJUSTMENT_ID AND LINE_ID = @LINE_ID ";
        private string SQL_INSERT_ADJUSTMENT_DETAIL = " INSERT INTO @_@ADJUSTMENT_DETAIL ( WH_ID, ADJUSTMENT_ID, LINE_ID, OWNER_ID, SKU_ID, LOC, LOT, LPN_ID, REASON_CODE, UOM_ID, PACK_ID, QTY, CASE_CNT, INNER_PACK, PALLET, CUBE, GROSS_WGT, NET_WGT, OTHER_UNIT1, OTHER_UNIT2, TRANS_ID, ADJUSTMENT_DATE, RECEIPT_ID, RECEIPT_LINE_ID, REFERENCE_ID, REMARK, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @ADJUSTMENT_ID, @LINE_ID, @OWNER_ID, @SKU_ID, @LOC, @LOT, @LPN_ID, @REASON_CODE, @UOM_ID, @PACK_ID, @QTY, @CASE_CNT, @INNER_PACK, @PALLET, @CUBE, @GROSS_WGT, @NET_WGT, @OTHER_UNIT1, @OTHER_UNIT2, @TRANS_ID, @ADJUSTMENT_DATE, @RECEIPT_ID, @RECEIPT_LINE_ID, @REFERENCE_ID, @REMARK, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_ADJUSTMENT_DETAIL = "SELECT DISTINCT A.ROWID, A.WH_ID, A.ADJUSTMENT_ID, A.LINE_ID, A.OWNER_ID, A.SKU_ID, A.LOC, A.LOT, A.LPN_ID, A.REASON_CODE, A.UOM_ID, A.PACK_ID, A.QTY, A.CASE_CNT, A.INNER_PACK, A.PALLET, A.CUBE, A.GROSS_WGT, A.NET_WGT, A.OTHER_UNIT1, A.OTHER_UNIT2, A.TRANS_ID, A.ADJUSTMENT_DATE, A.RECEIPT_ID, A.RECEIPT_LINE_ID, A.REFERENCE_ID, A.REMARK, A.TS, A.CREATED_BY, A.CREATED_DATE, A.UPDATED_BY, A.UPDATED_DATE,B.DESCR  FROM @_@ADJUSTMENT_DETAIL A  INNER JOIN @_@SKU B ON A.OWNER_ID = B.OWNER_ID AND A.SKU_ID = B.SKU_ID  ";
        private string SQL_UPDATE_ADJUSTMENT_DETAIL = " UPDATE @_@ADJUSTMENT_DETAIL SET WH_ID = @WH_ID, OWNER_ID = @OWNER_ID, SKU_ID = @SKU_ID, LOC = @LOC, LOT = @LOT, LPN_ID = @LPN_ID, REASON_CODE = @REASON_CODE, UOM_ID = @UOM_ID, PACK_ID = @PACK_ID, QTY = @QTY, CASE_CNT = @CASE_CNT, INNER_PACK = @INNER_PACK, PALLET = @PALLET, CUBE = @CUBE, GROSS_WGT = @GROSS_WGT, NET_WGT = @NET_WGT, OTHER_UNIT1 = @OTHER_UNIT1, OTHER_UNIT2 = @OTHER_UNIT2, TRANS_ID = @TRANS_ID, ADJUSTMENT_DATE = @ADJUSTMENT_DATE, RECEIPT_ID = @RECEIPT_ID, RECEIPT_LINE_ID = @RECEIPT_LINE_ID, REFERENCE_ID = @REFERENCE_ID, REMARK = @REMARK, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ADJUSTMENT_ID = @ADJUSTMENT_ID AND LINE_ID = @LINE_ID  ";
        private string TRANS_ID = "@TRANS_ID";
        private string TS = "@TS";
        private string UOM_ID = "@UOM_ID";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public int DeleteAdjustmentDetail(string adjustmentDetailID, List<string> LineID, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < LineID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ADJUSTMENT_ID", adjustmentDetailID), new SqlParameter("@LINE_ID", LineID[j]) };
                    result += DBHelper.ExecuteNonQuery(CommandType.Text, this.SQL_DELETE_ADJUSTMENT_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public AdjustmentDetailInfo GetAdjustmentDetailByID(string adjustmentID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ADJUSTMENT_DETAIL.Replace("@_@", whLoginID) + " WHERE A.ADJUSTMENT_ID = @ADJUSTMENT_ID  ORDER BY A.LINE_ID ASC ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ADJUSTMENT_ID", adjustmentID) };
            AdjustmentDetailInfo adjustmentdetail = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    adjustmentdetail = new AdjustmentDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ADJUSTMENT_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOC"].ToString(), reader["LOT"].ToString(), reader["LPN_ID"].ToString(), reader["REASON_CODE"].ToString(), reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["TRANS_ID"].ToString(), (reader["ADJUSTMENT_DATE"].ToString() != "") ? DateTime.Parse(reader["ADJUSTMENT_DATE"].ToString()) : (CS00002 = new DateTime()), reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["REFERENCE_ID"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["Descr"].ToString());
                }
            }
            return adjustmentdetail;
        }

        public AdjustmentDetailInfo GetAdjustmentDetailByID(DataBase dataBase, DbTransaction tran, string adjustmentID, string whLoginID)
        {
            string sql = "SELECT  A.ROWID, A.WH_ID, A.ADJUSTMENT_ID, A.LINE_ID, A.OWNER_ID, A.SKU_ID, A.LOC, A.LOT, A.LPN_ID, A.REASON_CODE, A.UOM_ID, A.PACK_ID, A.QTY, A.CASE_CNT, A.INNER_PACK, A.PALLET, A.CUBE, A.GROSS_WGT, A.NET_WGT, A.OTHER_UNIT1, A.OTHER_UNIT2, A.TRANS_ID, A.ADJUSTMENT_DATE, A.RECEIPT_ID, A.RECEIPT_LINE_ID, A.REFERENCE_ID, A.REMARK, A.TS, A.CREATED_BY, A.CREATED_DATE, A.UPDATED_BY, A.UPDATED_DATE,B.DESCR  FROM @_@ADJUSTMENT_DETAIL A  INNER JOIN @_@SKU B ON A.SKU_ID = B.SKU_ID ".Replace("@_@", whLoginID) + " WHERE ADJUSTMENT_ID = @ADJUSTMENT_ID ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ADJUSTMENT_ID", adjustmentID) };
            AdjustmentDetailInfo adjustmentdetail = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                DateTime CS00003;
                adjustmentdetail = new AdjustmentDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ADJUSTMENT_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOC"].ToString(), reader["LOT"].ToString(), reader["LPN_ID"].ToString(), reader["REASON_CODE"].ToString(), reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["TRANS_ID"].ToString(), (reader["ADJUSTMENT_DATE"].ToString() != "") ? DateTime.Parse(reader["ADJUSTMENT_DATE"].ToString()) : (CS00003 = new DateTime()), reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["REFERENCE_ID"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime(), reader["Descr"].ToString());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return adjustmentdetail;
        }

        public List<AdjustmentDetailInfo> GetAdjustmentDetailListByID(string adjustmentID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ADJUSTMENT_DETAIL.Replace("@_@", whLoginID) + " WHERE A.ADJUSTMENT_ID = @ADJUSTMENT_ID  ORDER BY A.LINE_ID ASC";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ADJUSTMENT_ID", adjustmentID) };
            List<AdjustmentDetailInfo> adjustmentdetailList = new List<AdjustmentDetailInfo>();
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    AdjustmentDetailInfo adjustmentInfo = new AdjustmentDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ADJUSTMENT_ID"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["OWNER_ID"].ToString(), reader["SKU_ID"].ToString(), reader["LOC"].ToString(), reader["LOT"].ToString(), reader["LPN_ID"].ToString(), reader["REASON_CODE"].ToString(), reader["UOM_ID"].ToString(), reader["PACK_ID"].ToString(), (reader["QTY"].ToString() != "") ? decimal.Parse(reader["QTY"].ToString()) : 0M, (reader["CASE_CNT"].ToString() != "") ? decimal.Parse(reader["CASE_CNT"].ToString()) : 0M, (reader["INNER_PACK"].ToString() != "") ? decimal.Parse(reader["INNER_PACK"].ToString()) : 0M, (reader["PALLET"].ToString() != "") ? decimal.Parse(reader["PALLET"].ToString()) : 0M, (reader["CUBE"].ToString() != "") ? ((double) float.Parse(reader["CUBE"].ToString())) : ((double) 0f), (reader["GROSS_WGT"].ToString() != "") ? ((double) float.Parse(reader["GROSS_WGT"].ToString())) : ((double) 0f), (reader["NET_WGT"].ToString() != "") ? ((double) float.Parse(reader["NET_WGT"].ToString())) : ((double) 0f), (reader["OTHER_UNIT1"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT1"].ToString())) : ((double) 0f), (reader["OTHER_UNIT2"].ToString() != "") ? ((double) float.Parse(reader["OTHER_UNIT2"].ToString())) : ((double) 0f), reader["TRANS_ID"].ToString(), (reader["ADJUSTMENT_DATE"].ToString() != "") ? DateTime.Parse(reader["ADJUSTMENT_DATE"].ToString()) : (CS00002 = new DateTime()), reader["RECEIPT_ID"].ToString(), (reader["RECEIPT_LINE_ID"].ToString() != "") ? int.Parse(reader["RECEIPT_LINE_ID"].ToString()) : 0, reader["REFERENCE_ID"].ToString(), reader["REMARK"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["Descr"].ToString());
                    adjustmentdetailList.Add(adjustmentInfo);
                }
            }
            return adjustmentdetailList;
        }

        public int InsertAdjustmentDetail(DataBase dataBase, DbTransaction tran, AdjustmentDetailInfo adjustmentDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                adjustmentDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_AdjustmentDetail_Parameters(adjustmentDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_ADJUSTMENT_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_AdjustmentDetail_Parameters(AdjustmentDetailInfo adjustmentDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.ADJUSTMENT_ID, SqlDbType.VarChar, 20), new SqlParameter(this.LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.OWNER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.SKU_ID, SqlDbType.VarChar, 50), new SqlParameter(this.LOC, SqlDbType.VarChar, 20), new SqlParameter(this.LOT, SqlDbType.VarChar, 20), new SqlParameter(this.LPN_ID, SqlDbType.VarChar, 20), new SqlParameter(this.REASON_CODE, SqlDbType.VarChar, 20), new SqlParameter(this.UOM_ID, SqlDbType.VarChar, 20), new SqlParameter(this.PACK_ID, SqlDbType.VarChar, 50), new SqlParameter(this.QTY, SqlDbType.Decimal, 13), new SqlParameter(this.CASE_CNT, SqlDbType.Decimal, 13), new SqlParameter(this.INNER_PACK, SqlDbType.Decimal, 13), new SqlParameter(this.PALLET, SqlDbType.Decimal, 13), new SqlParameter(this.CUBE, SqlDbType.Float, 8), 
                new SqlParameter(this.GROSS_WGT, SqlDbType.Float, 8), new SqlParameter(this.NET_WGT, SqlDbType.Float, 8), new SqlParameter(this.OTHER_UNIT1, SqlDbType.Float, 8), new SqlParameter(this.OTHER_UNIT2, SqlDbType.Float, 8), new SqlParameter(this.TRANS_ID, SqlDbType.VarChar, 20), new SqlParameter(this.ADJUSTMENT_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.RECEIPT_ID, SqlDbType.VarChar, 20), new SqlParameter(this.RECEIPT_LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.REFERENCE_ID, SqlDbType.VarChar, 20), new SqlParameter(this.REMARK, SqlDbType.VarChar, 0x3e8), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(adjustmentDetailInfo.WhID))
            {
                paramArray[0].Value = adjustmentDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = adjustmentDetailInfo.AdjustmentID;
            paramArray[2].Value = adjustmentDetailInfo.LineID;
            paramArray[3].Value = adjustmentDetailInfo.OwnerID;
            paramArray[4].Value = adjustmentDetailInfo.SkuID;
            paramArray[5].Value = adjustmentDetailInfo.Loc;
            paramArray[6].Value = adjustmentDetailInfo.Lot;
            paramArray[7].Value = adjustmentDetailInfo.LpnID;
            paramArray[8].Value = adjustmentDetailInfo.ReasonCode;
            paramArray[9].Value = adjustmentDetailInfo.UomID;
            paramArray[10].Value = adjustmentDetailInfo.PackID;
            paramArray[11].Value = adjustmentDetailInfo.Qty;
            paramArray[12].Value = adjustmentDetailInfo.CaseCnt;
            paramArray[13].Value = adjustmentDetailInfo.InnerPack;
            paramArray[14].Value = adjustmentDetailInfo.Pallet;
            paramArray[15].Value = adjustmentDetailInfo.Cube;
            paramArray[0x10].Value = adjustmentDetailInfo.GrossWgt;
            paramArray[0x11].Value = adjustmentDetailInfo.NetWgt;
            paramArray[0x12].Value = adjustmentDetailInfo.OtherUnit1;
            paramArray[0x13].Value = adjustmentDetailInfo.OtherUnit2;
            paramArray[20].Value = adjustmentDetailInfo.TransID;
            paramArray[0x15].Value = adjustmentDetailInfo.AdjustmentDate;
            if (!string.IsNullOrEmpty(adjustmentDetailInfo.ReceiptID))
            {
                paramArray[0x16].Value = adjustmentDetailInfo.ReceiptID;
            }
            else
            {
                paramArray[0x16].Value = DBNull.Value;
            }
            paramArray[0x17].Value = adjustmentDetailInfo.ReceiptLineID;
            if (!string.IsNullOrEmpty(adjustmentDetailInfo.ReferenceID))
            {
                paramArray[0x18].Value = adjustmentDetailInfo.ReferenceID;
            }
            else
            {
                paramArray[0x18].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(adjustmentDetailInfo.Remark))
            {
                paramArray[0x19].Value = adjustmentDetailInfo.Remark;
            }
            else
            {
                paramArray[0x19].Value = DBNull.Value;
            }
            paramArray[0x1a].Value = adjustmentDetailInfo.CreatedBy;
            paramArray[0x1b].Value = adjustmentDetailInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateAdjustmentDetail(DataBase dataBase, DbTransaction tran, AdjustmentDetailInfo adjustmentDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                adjustmentDetailInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_AdjustmentDetail_Parameters(adjustmentDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_ADJUSTMENT_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

